(function($) {
	'use strict';


	// mousewheel
	$('body').on('DOMMouseScroll mousewheel', function(e) {
		var $header = $('.scroll-header');
		if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
			$header.removeClass('scroll-up').addClass('scroll-down');
		} else {
			$header.removeClass('scroll-down').addClass('scroll-up');
		}
		if ($(window).scrollTop() == 0) {
			$header.removeClass('scroll-up scroll-down');
		}
	});

	// mousewheel
	$('.swapimg .handler').on('mousemove', function(e) {
		var offset = $(this).parent().offset();
		var X = Math.round(e.pageX - offset.left);
		console.log(X);
		$(this).parent().width(X);
	});

	// nav
	$(document).on('click', '[data-nav] a', function(e) {
		var $this = $(this),
			$active, $li, $li_li;

		$li = $this.parent();
		$li_li = $li.parents('li');

		$active = $li.closest("[data-nav]").find('.active');

		$li_li.addClass('active');
		($this.next().is('ul') && $li.toggleClass('active')) || $li.addClass('active');

		$active.not($li_li).not($li).removeClass('active');

		if ($this.attr('href') && $this.attr('href') != '#') {
			$(document).trigger('Nav:changed');
		}
	});

	var init = function() {

			(typeof feather !== 'undefined') && feather.replace({
				'width': 16,
				'height': 16
			});

			// active nav item
			var url = window.location.pathname.split('/');
			if (url.length > 0) url = url[url.length - 1];
			$('[data-nav]:not(.auto-nav) li.active').removeClass('active');
			$('[data-nav]:not(.auto-nav) a').filter(function() {
				return url == $(this).attr('href') && $(this).attr('href') !== '#';
			}).parents('li').addClass('active');
			
			
			$(".fancybox-button").fancybox({
				prevEffect		: 'none',
				nextEffect		: 'none',
				closeBtn		: false,
				helpers		: {
					title	: { type : 'inside' },
					buttons	: {}
				}
			});
			
			
			
		}
	
	init();

})(jQuery);